#!/bin/dash

args="-listonly -dump"
dl=0

for arg in "$@"; do
    case ${arg} in
        -n)
            args="${args} -nonumbers"
            ;;
        -d)
            dl=1
    esac
done

links=$(lynx ${args} $1)
echo "${links}"

if [ ${dl} -eq 1 ]; then
    #echo "${links}" | grep '\.[a-zA-Z0-9]\{0,9\}' | while read -r l; do
    echo "${links}" | grep -v '/$' | while read -r l; do
        f=$(echo "$l" | sed 's:.*/::')
        echo "downlaoding $f"
        curl -A "keknoagentforu/69.0" "$l" >> "$f"
    done
fi
